<?php
class NewsController extends AppController {

    public $layout = 'main';

    function beforeFilter() {
        parent::beforeFilter(); 
    }

    function index($id=null){
        $id = $this->rm_end_html($id);
	    $this->loadModel('News');
        $this->loadModel('NewsClasse');
	    // $news=$this->News->find("all",array('limit'=>9,'order'=>array('id' =>'desc'))); 
        $newsclass=$this->NewsClasse->find("all",array()); 

        if(!empty($id)){
            $cates = $this->News->find('all',array('conditions'=>array('class'=>$id)));
            
        }else{
            $cates = $this->News->find('all',array('limit'=>9,'order'=>array('id' =>'desc')));
        }
	    $this->paginate = array(                                        //利用分页取出数据
            'order'=>array('id' =>'desc'),
            'limit'=>10
        );
        try{
            $case = $this->paginate('News');
        }catch(NotFoundException $e){
            $case = array();
        }
        $this->set("newsclass",$newsclass); 
        $this->set('new',$cates); 
    }
    function info(){
        $this->loadModel('News');
        $this->loadModel('NewsClasse');
        $news=$this->News->find("all",array()); 
        $newsclass=$this->NewsClasse->find("all",array()); 
        $this->set("news",$news); 
        $this->set("newsclass",$newsclass); 
    }

}